package com.yingpai.fitness.dvp_2_0.main.adapter.shop;

import android.support.annotation.LayoutRes;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yingpai.fitness.R;
import com.yingpai.fitness.entity.ShopSaleData;

import java.text.DecimalFormat;

public class ShopSaleRecyclerAdapter extends BaseQuickAdapter<ShopSaleData.MapBean.PageInfoBean.ListBean, BaseViewHolder> {

    private DecimalFormat df = new DecimalFormat("######.###");
    public ShopSaleRecyclerAdapter(@LayoutRes int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(BaseViewHolder helper, ShopSaleData.MapBean.PageInfoBean.ListBean item) {
        ImageView shop_sale_shop_cover_iv = helper.getView(R.id.shop_sale_shop_cover_iv);//图片封面

        Glide.with(helper.getConvertView().getContext())
                .load(item.getPhotoUrls().contains(",") ? item.getPhotoUrls().substring(0, item.getPhotoUrls().indexOf(",")) : item.getPhotoUrls())
                .error(R.mipmap.default_small_bg)
                .into(shop_sale_shop_cover_iv);

        helper.addOnClickListener(R.id.listitem_zone);


        TextView shop_sale_shop_title_tv = helper.getView(R.id.shop_sale_shop_title_tv);//商品标题
        shop_sale_shop_title_tv.setText(item.getMerchandiseName());

        TextView sales = helper.getView(R.id.sales);
        sales.setText("自营"/* + item.getSalesAmount()*/);

        TextView shop_sale_shop_vip_price_tv = helper.getView(R.id.shop_sale_shop_vip_price_tv);//会员价格
        shop_sale_shop_vip_price_tv.setText(/*"会员价：￥"+*/df.format(item.getMemberPrice() / 100) + "");
    }


}
